import jsonschema
# 导包
dic1={"name":"zhangsan","age":18,"sex":True,"hobby":"港哥上课看美女"}
# 待校验的数据

schema={
    "type":"object",
    "properties":{
        "name":{"const":"zhangsan"},
        "age":{"const":18},
        "sex":{"const":True},
        "habby":{"pattern":"港哥$"}
    },
    "required":["name","age","sex"]

}
# 定义规则
res=jsonschema.validate(instance=dic1,schema=schema)

# 校验
print(res)